<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								计划编号：<input type="text" name="iD"/>
							</li>
							<li>
								商户编号：<input type="text" name="merchantNo"/>
							</li>
							<li>
								商户名称：<input type="text" name="merchantName"/>
							</li>
							<!-- 借用 brokerId 传顾问编号筛选条件-->
							<li>
								顾问编号：<input type="text" name="brokerId"/>
							</li>
							<li>
								计划状态：<select name="sTATUS" th:with="type=${@dict.getType('plan_sTATUS')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a id ="btnSearch" class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<font><b>计划总金额：</b><span id="spanSumMoney" > </span>元</font>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
       /*  var editFlag = [[${@permission.hasPermi('system:hatchetPlan:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:hatchetPlan:remove')}]]; */
       //状态数据查询字典表显示
        var sTATUS = [[${@dict.getType('plan_sTATUS')}]];
        var prefix = ctx + "system/hatchetPlan";

        $(function() {
        	//点击总金额清零
        	$("#btnSearch").click(function(){
        		$("#spanSumMoney").text(0);
        	});
            var options = {
                url: prefix + "/list",
                /* createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export", */
                modalName: "	还款计划",
				search: false,
		        showExport: false,//是否有导表按钮
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '计划ID',
					visible: true
				},
				{
					field : 'acqName', 
					title : '通 道 名 称',
					sortable: false
				},
				{
					field : 'merchantNo', 
					title : '商户编号',
					sortable: false
				},
				{
					field : 'merchantName', 
					title : '商户名称',
					sortable: false
				},
				{
					field : 'bankName', 
					title : '所属银行名称',
					sortable: false
				},
				{
					field : 'cardNo', 
					title : '信用卡号',
					sortable: false
				},
				{
					field : 'brokerId', 
					title : '顾问编号',
					sortable: false
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'planAmt', 
					title : '还款总金额(元)',
					sortable: true
				},
				{
					field : 'cbAmt', 
					title : '周转金(元)',
					sortable: true
				},
				{
					field : 'saleFree', 
					title : '手续费(元)',
					sortable: true
				},
				{
					field : 'payFree', 
					title : '笔数费(元)',
					sortable: true
				},
				{
					field : 'buckleFee', 
					title : '实扣手续费(元)',
					sortable: true
				},
				{
					field : 'bucklePay', 
					title : '实扣笔数费(元)',
					sortable: true
				},
				{
					field : 'sTATUS', 
					title : '使用状态',
					align: 'center',
					formatter: function(value, item, index) {
						if(item.sumMoney != null){
	            			$("#spanSumMoney").text(item.sumMoney);
	            		} 
		            	return $.table.selectDictLabel(sTATUS, item.status);
			            }
				},
				{
					field : 'startTime', 
					title : '开始时间',
					sortable: true
				},
				{
					field : 'endTime', 
					title : '终止时间',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, item, index) {
		            	var actions = [];
		            	if(item.status=="10A" || item.status=="10B") {
		            		 actions.push('<a class="btn btn-danger  btn-xs" href="#" onclick="disable(\''+item.id+'\')" ><i class="fa fa-remove"></i>禁用</a>');
		            	}else{
		            		actions.push('<a class="btn btn-success btn-xs" href="#" onclick="enable(\''+item.id+'\')" ><i class="fa fa-edit"></i>启用</a> ');
		            	} 
						return actions.join(''); 
		            }
		        }]
            };
            $.table.init(options);
        });
        function enable(id){
        	$.modal.confirm("确认要启用计划吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "iD": id, "sTATUS": "10A" });
		    })
        }
        function disable(id){
        	$.modal.confirm("确认要禁用计划吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "iD": id, "sTATUS": "10C" });
		    })
        }
         
      
        
    </script>
</body>
</html>